<template>
    <a-form layout="vertical" :model="formState" @finish="onFinish">
        <!-- 第一行 -->
        <a-row>
            <a-col :span="11">
                <a-form-item label="职级名称" name="levelName" hasFeedback :rules="[{
                    required: true, message: '职级名称为必填项',
                }]">
                    <a-input v-model:value="formState.levelName"></a-input>
                </a-form-item>
            </a-col>
            <a-col :span="11" class="ml-40">
                <a-form-item label="职级描述" name="levelDescription" hasFeedback
                :rules="[{
                    required: true, message: '职级描述为必填项',
                }]">
                    <a-input v-model:value="formState.levelDescription"></a-input>
                </a-form-item>
            </a-col>
        </a-row>
        <!-- 第二行 -->
        <a-row>
            <a-col :span="11">
                <a-form-item label="考核要求" name="assessmentRequire" hasFeedback :rules="[{
                    required: true, message: '考核要求为必填项',
                }]">
                    <a-input v-model:value="formState.assessmentRequire"></a-input>
                </a-form-item>
            </a-col>
            <a-col :span="11" class="ml-40">
                <a-form-item label="面试要求" name="interviewRequire" hasFeedback
                :rules="[{
                    required: true, message: '面试要求为必填项',
                }]"
                >
                    <a-input v-model:value="formState.interviewRequire"></a-input>
                </a-form-item>

            </a-col>
        </a-row>
        <!-- 第三行 -->
        <a-row>
            <a-col :span="11">
                <a-form-item label="分红权基数" name="baseNumber" hasFeedback
                :rules="[{
                    required: true, message: '分红权基数为必填项',
                }]"
                >
                    <a-input v-model:value="formState.baseNumber"></a-input>
                </a-form-item>
            </a-col>
            <a-col :span="11" class="ml-40">
                <a-form-item label="职级标准分数" name="levelScore" hasFeedback
                :rules="[{
                    required: true, message: '学历为必填项',
                }]"
                >
                    <a-input v-model:value="formState.levelScore"></a-input>
                </a-form-item>

            </a-col>
        </a-row>
        <a-row>
            <a-col :span="24" style="text-align: right;">
                <a-button type="primary" html-type="submit" class="mr-25">创建</a-button>
            </a-col>
        </a-row>
    </a-form>
</template>

<script setup lang="ts">
import appStore from "@/store";
import apis from '@/apis/index';
import { message } from "ant-design-vue";
const props = defineProps({
    dialogStatus: {
        type: Boolean,
        default: false,
    },
    setDialogStatus: {
        type: Function,
        default: () => {},
    }
});
const formState = reactive({
    levelName: '',
    levelDescription: '',
    assessmentRequire: '',
    interviewRequire: '',
    baseNumber: '',
    levelScore: '',
});
const onFinish = async (values) => {
    console.log('onfinish', values);
    // const temp = {
    //     birthday: new Date(formState.birthday),
    //     onboardingTime: new Date(formState.onboardingTime),
    // };
    const params = {
        ...formState,
    };
    
    const res = await apis.level.addLevel_API(params);
    console.log(res,'addd')
    if (res) {
        props.setDialogStatus(false);
        message.success('职级添加成功');
        return;
    }
    message.error('职级添加失败');
}
onMounted(() => { });
</script>

<style  lang="less" scoped>
input {
    width: 100%;
}

.ant-picker {
    width: 100%;
}

.ml-40 {
    margin-left: 40px;
}

.mr-25 {
    margin-right: 25px;
}
</style>
